﻿@using LotteryVoteMVC.Core
@using LotteryVoteMVC.Models
@using LotteryVoteMVC.Resources
@using LotteryVoteMVC.Utility
@using LotteryVoteMVC.Core.Application
@model PagedList<BetOrder>
@{
    ViewBag.Title = @Resource.WinLost;
    Layout = "~/Views/Shared/Main.cshtml";
}
@section Header
{
    <script src="@Url.Content("~/Scripts/Customer/SearchHelper.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.ui.datepicker.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.ui.datepicker-" + CultureHelper.GetCurrentCulture() + ".js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/Customer/TableBase.js")" type="text/javascript"></script>
    <link href="@Url.Content("~/Content/themes/base/jquery.ui.theme.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/themes/base/jquery.ui.datepicker.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/TableBase.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/Pager/pagerGray.css")" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        $(document).ready(function () {
            $("#Date").attr("readonly", "readonly").datepicker();
        });
    </script>
}
@{
    int index = 1;
    decimal amount = 0, turnover = 0, comm = 0, netamount = 0, winlost = 0;
}
<div id="searchBar">
    @using (Html.BeginForm())
    {
        <span>@Resource.Time</span>
        @Html.TextBox("Date", DateTime.Today.ToShortDateString())
        <span>@Resource.Num</span>
        @Html.TextBox("Num")
        <span>@Resource.Company</span>
        @Html.Action("TodayCompany", "Partial")
        <span>@Resource.GameType</span>
        @Html.Action("GamePlayWay", "Partial")
        <span>@Resource.WinLost</span>
        <select name="WinLost" id="WinLost">
            <option value="@WinLost.All">@Resource.All</option>
            <option value="@WinLost.Win">@Resource.Win</option>
            <option value="@WinLost.Lost">@Resource.Lost</option>
        </select>
        <input type="submit" id="search" name="search" value="@Resource.Search" />
    }
</div>
<table>
    <thead>
        <tr>
            <td>
                @Resource.No
            </td>
            <td>
                @Resource.OrderNum
            </td>
            <td>
                @Resource.Num
            </td>
            <td>
                @Resource.Company
            </td>
            <td colspan="2">
                @Resource.GameType
            </td>
            <td>
                @Resource.Amount
            </td>
            <td>
                @Resource.Turnover
            </td>
            <td>
                @Resource.Odds
            </td>
            <td>
                @Resource.Commission
            </td>
            <td>
                @Resource.Net
            </td>
            <td>
                @Resource.NetAmount
            </td>
            <td>
                @Resource.WinLost
            </td>
            <td>
                @Resource.Time
            </td>
        </tr>
    </thead>
    <tbody>
        @foreach (var order in Model)
        { 
            <tr>
                <td>
                    @(index++)
                </td>
                <td>
                    @order.OrderId
                </td>
                <td>
                    @order.Num
                </td>
                <td>
                    @LotterySystem.Current.FindCompany(order.CompanyId).Name
                </td>
                <td>
                    @{var gpw = LotterySystem.Current.FindGamePlayWay(order.GamePlayWayId);}
                    @gpw.GameType.GetDesc()
                </td>
                <td>
                    @gpw.PlayWay.ToStr()
                </td>
                <td>
                    @order.Amount.ToString("N")
                </td>
                <td>
                    @order.Turnover.ToString("N")
                </td>
                <td>
                    @order.Odds
                </td>
                <td>
                    @order.Commission.ToString("N")
                </td>
                <td class="@(order.DropWater > 0 ? "red" : "")">
                    @order.Net
                </td>
                <td>
                    @order.NetAmount.ToString("N")
                </td>
                <td class="@(order.DrawResult < 0 ? "red" : "")">
                    @order.DrawResult.ToString("N")
                </td>
                <td>
                    @order.CreateTime
                </td>
            </tr>
                      amount += order.Amount;
                      turnover += order.Turnover;
                      comm += order.Commission;
                      netamount += order.NetAmount;
                      winlost += order.DrawResult;
        }
    </tbody>
    <tfoot>
        <tr>
            @for (int i = 0; i < 5; i++)
            { 
                <td>
                </td>
            }
            <td>@Resource.Total
            </td>
            <td>@amount.ToString("N")
            </td>
            <td>@turnover.ToString("N")
            </td>
            <td>
            </td>
            <td>@comm.ToString("N")
            </td>
            <td>
            </td>
            <td>@netamount.ToString("N")
            </td>
            <td class="@(winlost < 0 ? "red" : "")">@winlost.ToString("N")
            </td>
            <td>
            </td>
        </tr>
    </tfoot>
</table>
@Html.Pager(Model)
